package com.yanqu.road.server.channelserver.cmd.server;

import com.yanqu.road.logic.xlogic.server.XServerNameMap;
import com.yanqu.road.pb.cross3.server.CrossChannelServerProto;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.server.protocol.ChannelProtocol;
import com.yanqu.road.server.channelserver.cmd.ChannelCommand;
import com.yanqu.road.server.channelserver.manager.server.ChannelXServerNameMgr;

@Cmd(code = ChannelProtocol.N_UPLOAD_SERVER_NAME, desc = "上传区服名称")
public class UploadCrossChannelServerNameCmd extends ChannelCommand {

    @Override
    public boolean parseData(YanQuMessage packet) throws Exception {
        XServerNameMap serverNameMap = ChannelXServerNameMgr.getServerNameMap();
        CrossChannelServerProto.ServerNameListMsg reqMsg = CrossChannelServerProto.ServerNameListMsg.parseFrom(packet.getBytes());
        for (CrossChannelServerProto.ServerNameMsg msg : reqMsg.getNameListList()) {
            serverNameMap.addServerName(msg.getChannelId(), msg.getServerId(), msg.getServerName());
        }
        return true;
    }

    @Override
    public void execute(YanQuMessage packet) throws Exception {

    }

    @Override
    public void sendData() {

    }
}
